window.onload = function() {
	seajs.use(['jquery-1.8.2.js', 'iscroll_module.js', 'mdialog_module.js', 'util_module.js'], function(Z, I, M, U) {
		var user = U.checkLogin();
		U.fillHead();
		U.fillFooter();
		var URL=decodeURI(document.location.search);

		/*var title = U.getParamUrl("title",URL),progress=U.getParamUrl("progress",URL),totalAmount= U.getParamUrl("totalAmount",URL),residualTime= U.getParamUrl("residualTime",URL),images= U.getParamUrl("images",URL),intro= U.getParamUrl("intro",URL),progressValue=U.getParamUrl("progress",URL)+"%",gmtCreate=U.getParamUrl("gmtCreate",URL);*/
		initPage();


		function initPage() { //初始化页面
			U.loadOpt(false);

			U.ajaxget("/crowd/specialDetail/"+U.getParamUrl("id",URL), "", function(json) {
				if(json.success){
					var info=json.models.specialDetail;
					var title=info.title;
					var residualTime=info.residualTime;
					var day=residualTime.substring(0,residualTime.length-1);
					var percentage=info.progress.substring(0,info.progress.length-1);
					$(".announcement_details>div:first-child").text(title);
					var adv ="<script  src='js/jquery.progress.js'></script>";
					var jindu=adv+"<div class='crowd-center'>" +
						"<div class='progress'>" +
						"<svg class='container' data-value='"+percentage+"'></svg>" +
						"</div>" +
						"</div>" +
						"<div class='crowd-bottom'>" +
						"<div class='crowd-bottom-item'>" +
						"<span class='sp3'>"+(info.state==3?"":"已达")+"<span class='sp2'>"+(info.state==3?"已完成":info.progress)+"</span></span>" +
						"</div>" +
						"<div class='crowd-bottom-item'>" +
						"<span class='sp3'>已筹款<span class='sp2'>"+(info.totalAmount/100)+"</span>元</span>" +
						"</div>" +
						"<div class='crowd-bottom-item'>" +
						"<span class='sp3'>"+(info.state==3?"":"剩余时间")+"<span class='sp2'>"+(info.state==3?"已完成":(day<1?"已完成":info.residualTime))+"</span></span>" +
						"</div>" +
						"</div>" ;
					$(".jindu").append(jindu);
					$(".gmtCreate").html(U.getMyDate(info.gmtCreate));
					var sr="<script> $('.container').each(function(){var progress = $(this).Progress({percent: $(this).attr('data-value'),width: 568,height:10,fontSize: 0});}); </script>"

					var btn="<span class='juanzhu' style=' width: 128px;height: 50px;background-color: #ff6600;display: block;border-radius: 5px;text-align: center;line-height: 50px;color: #fff;font-size: 19px;font-weight: bold;cursor:pointer;margin: 0 auto;'>我要捐助</span>";

					if(info.state == 3 || percentage>=100 || day <1){
						$(".jindu_right").css("display","none");
					}

					$(".jindu").append(sr);
					var list="<div><div class='detail_left'><img src='"+info.images+"'></div><div class='detail_right'><div class='rightBody'>"+info.intro+"</div></div></div>";
					$(".help_list").append(list);


					U.ajaxget("/support/listAll" , {crowdId:U.getParam("id")}, function(json) {
						if(json.success) {

							$(".jindu_right").empty();
							$(".jindu_right").append(btn);
							$(".juanzhu").click(function(){
								window.open("help_entrance.html?crowdId=" + U.getParam("id") + "&title=" + title);
							});
							$(".stage_list>div").empty();
							$(json.models.supportRecordList).each(function(i) {
								var item="<div style='width: 90%; margin-top: 27px'><div><span style='display: block;width: 10px;height: 10px;background-color: #DEDEDE;float: left;margin-top: 5px'></span><span style='display: block;margin-left: 20px'>"+U.getMyDate(this.gmtModify)+"</span></div><div style='margin-top: 17px'><span style='clear: left;display: block;margin-left: 20px'>"+this.content+"</span></div></div>"
								$(".stage_list").append(item);
							});
						} else {
							M.toast(false, json.errorMsg);
						}
					});
				}
			})



		}

	});
};